/* eslint-disable no-underscore-dangle */
import { Record } from 'immutable';

const DEFAULTS = {
  width: undefined,
  height: undefined,
  minWidth: undefined,
  maxWidth: undefined,
  maxHeight: undefined,
  minHeight: undefined,
  display: 'block',
  zIndex: 10,
  fontSize: '14px',
  fontStyle: 'normal',
  color: '#595959',
};

class Style extends Record(DEFAULTS) {
  static create(attr = {}) {
    return Style.fromJSON(attr);
  }

  static fromJSON(object = {}) {
    if (Style.isStyle(object)) {
      return object;
    }
    const {
      width,
      minWidth,
      maxWidth,
      minHeight,
      maxHeight,
      height,
      display,
      zIndex,
      fontSize,
      fontWeight,
      color,
    } = object;
    return new Style({
      width,
      height,
      display,
      minHeight,
      minWidth,
      maxHeight,
      maxWidth,
      zIndex,
      fontSize,
      fontWeight,
      color,
    });
  }
}

Style.prototype.__style__ = true;
export default Style;
